/*
 * EditTextDialog.h
 *
 *  Created on: 2024年9月13日
 *      Author: nwz
 */

#ifndef CODE_EDITTEXTDIALOG_H_
#define CODE_EDITTEXTDIALOG_H_
#include <wx/wx.h>
#include <wx/string.h>
#include <wx/wrapsizer.h>
class EditTextDialog: public wxDialog {
public:
	EditTextDialog(wxWindow *parent) :
			parent { parent } {

	}

	virtual ~EditTextDialog() {

	}

	void init() {
		Create(parent, wxID_ANY, "", wxDefaultPosition, wxDefaultSize,
				wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
		auto lay = new wxBoxSizer(wxVERTICAL);

		{
			auto text = new wxTextCtrl(this, wxID_ANY, "");
			lay->Add(text,wxSizerFlags().Expand());

			auto lay2 = new wxBoxSizer(wxHORIZONTAL);
			auto btnOk = new wxButton(this, wxID_OK, _("OK"));
			auto btnCancel = new wxButton(this, wxID_CANCEL, _("cancnel"));
			lay2->Add(btnOk,wxSizerFlags().Border(wxALL, 7));
			lay2->Add(btnCancel,wxSizerFlags().Border(wxALL, 7));
			lay->Add(lay2,wxSizerFlags().Center());

			u_text = text;
		}

		SetSizer(lay);
		Layout();
	}

	void setText(wxString text) {
		u_text->SetValue(text);
	}

	wxString getText() {
		return u_text->GetValue();
	}

private:
	wxTextCtrl *u_text;
	wxWindow *parent;
};

#endif /* CODE_EDITTEXTDIALOG_H_ */
